#include "trap.h"
#include "../include/arithmetic_test.h"
   .set noat
   .globl main
   .set noreorder
   .text
main:
   TEST_ADD(0x00000001, 0x00000001, 0x00000002) # 两个正数相加
   TEST_ADD(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE) # 两个负数相加
   TEST_ADD(0x7FFFFFFF, 0x00000001, 0x80000000) # 正数和负数相加
   TEST_ADD_OV(0x7FFFFFFF, 0x00000001, 0x80000000) # 溢出
   
   TEST_ADDI(0x00000001, 0x00000001, 0x00000002) # 正常情况
   TEST_ADDI_OV(0x80000000, 0x0000FFFF, 0x7FFFFFFF) # 溢出
   
   TEST_ADDU(0x00000001, 0x00000001, 0x00000002) # 正常情况
   TEST_ADDU(0xFFFFFFFF, 0x00000001, 0x00000000) # 溢出情况

   TEST_ADDIU(0x00000001, 0x0000FFFF, 0x00000000) # 溢出情况 + 1 拓展
   TEST_ADDIU(0x00000001, 0x00007FFF, 0x00008000) # 0 拓展

   TEST_SUB(0x7FFFFFFF, 0x00000001, 0x7FFFFFFE) # 正数相减
   TEST_SUB(0xFFFFFFFF, 0xFFFFFFFE, 0x00000001) # 负数相减
   TEST_SUB_OV(0x80000000, 0x00000001, 0x7FFFFFFF) # 溢出

   TEST_SUBU(0x00000001, 0x00000001, 0x00000000) # 正常情况
   TEST_SUBU(0x80000000, 0x00000001, 0x7FFFFFFF) # 溢出情况

   TEST_SLT(0x80000000, 0x00000001, 0x00000001) # 正数和负数比较
   TEST_SLT(0x00000001, 0x80000000, 0x00000000) 
   TEST_SLT(0x00000001, 0x00000002, 0x00000001) # 正数和正数比较
   TEST_SLT(0x00000002, 0x00000001, 0x00000000)
   TEST_SLT(0xFFFFFFFF, 0xFFFFFFF0, 0x00000000) # 负数和负数比较
   TEST_SLT(0xFFFFFFFF, 0x00000000, 0x00000001)
   TEST_SLT(0x00000001, 0x00000001, 0x00000000) # 两数相等

   TEST_SLTI(0x80000000, 0x00000001, 0x00000001) # 正数和负数比较
   TEST_SLTI(0x00000001, 0x00000002, 0x00000001) # 正数和正数比较
   TEST_SLTI(0x00000002, 0x00000001, 0x00000000)
   TEST_SLTI(0xFFFFFFFF, 0x00000000, 0x00000001)
   TEST_SLTI(0x00000001, 0x00000001, 0x00000000) # 两数相等

   TEST_DIV(0x00000002, 0x00000001, 0x00000002, 0x00000000) # 正数相除
   TEST_DIV(0x80000000, 0x00000001, 0x80000000, 0x00000000) # 正数和负数相除
   TEST_DIV(0xFFFFFFFF, 0xFFFFFFFF, 0x00000001, 0x00000000) # 负数相除

   TEST_DIVU(0x00000002, 0x00000001, 0x00000002, 0x00000000) # 正数相除
   TEST_DIVU(0xFFFFFFFF, 0x80000000, 0x00000001, 0x80000000) # 负数相除

   TEST_MULT(0x00000001, 0x00000001, 0x00000001, 0x00000000) # 正数相乘
   TEST_MULT(0xFFFFFFFF, 0xFFFFFFFF, 0x00000001, 0x00000000) # 负数相乘
   TEST_MULT(0x80000000, 0x00000001, 0x80000000, 0xffffffff) # 正数和负数相乘

   TEST_MULTU(0x00000001, 0x00000001, 0x00000001, 0x00000000) # 正数相乘
   TEST_MULTU(0x80000001, 0x00000002, 0x00000002, 0x00000001) # 正数和负数相乘

   HIT_GOOD_TRAP		# 测试结束

inst_error:
   HIT_BAD_TRAP   # 出错